import { defineStore } from 'pinia'
import { computed, ref } from 'vue'

export const useCounterStore = defineStore(
  'counter',
  () => {
    const count = ref(0)
    const count2 = ref(0)

    const doubleCount = computed(() => count.value * 2)

    function increment() {
      count.value++
      count2.value++
    }

    function decrement() {
      count.value--
      count2.value--
    }

    return { count, count2, increment, decrement, doubleCount }
  },
  {
    unistorage: {
      key: 'sb-counter',
      paths: ['count'],
    },
  }
)
